(function (f) {
    if (typeof exports === "object" && typeof module !== "undefined") {
        module.exports = f()//支持Node、CommonJS之类的加载规范
    } else if (typeof define === "function" && define.amd) {
        define([], f)//支持AMD加载规范
    } else {
        var g;
        if (typeof window !== "undefined") {
            g = window
        } else if (typeof global !== "undefined") {
            g = global
        } else if (typeof self !== "undefined") {
            g = self
        } else {
            g = this
        }
        g.Utils = f()//默认构造函数
    }
})(function () {
    var define, module, exports;
    return (function e(t, n, r) {
        function s(o, u) {
            if (!n[o]) {
                if (!t[o]) {
                    var a = typeof require == "function" && require;
                    if (!u && a) return a(o, !0);
                    if (i)
                        return i(o, !0);
                    var f = new Error("Cannot find module '" + o + "'");
                    throw f.code = "MODULE_NOT_FOUND", f
                }
                var l = n[o] = { exports: {} };
                t[o][0].call(l.exports, function (e) {
                    var n = t[o][1][e]; return s(n ? n : e)
                }, l, l.exports, e, t, n, r)
            } return n[o].exports
        }
        var i = typeof require == "function" && require;
        for (var o = 0; o < r.length; o++) s(r[o]);
        return s
    })({
        1: [function (require, module, exports) {
            module.exports.DataPoint = require('./DataPoint');
            module.exports.GradientColor = require('./GradientColor');
            module.exports.RainfallDataAPI = require('./RainfallDataAPI');
            module.exports.RainfallLayer = require('./RainfallLayer');
            module.exports.SegmentedColor = require('./SegmentedColor');
        }, { './DataPoint':2,'./GradientColor':3,'./RainfallDataAPI':4,'./RainfallLayer':5,'./SegmentedColor':6}],
        2: [function (require, module, exports) {
        	
            var Point = require('esri/geometry/Point'),
                declare = require('dojo/_base/declare');                
            'use strict';
            var DataPoint = declare(null, {
                    startLon: null, //起始经度
                    startLat: null, //起始纬度
                    endLon: null, //终止经度
                    endLat: null, //终止纬度
                    lonCount: null, //经度跨度数量
                    latCount: null, //纬度跨度数量
                    lonStep: null, //经度步长
                    latStep: null, //纬度步长
                    ds: null, //源数据
                    pointsArr: [], //点集合

                    constructor: function (json) {
                        // console.log(json);
                        this.startLon = json.startLon;
                        this.startLat = json.startLat;
                        this.endLon = json.endLon;
                        this.endLat = json.endLat;
                        this.lonCount = json.lonCount;
                        this.latCount = json.latCount;
                        this.lonStep = json.lonStep;
                        this.latStep = json.latStep;
                        this.ds = json.DS;
                        this.calcPoints();
                    },

                    getPointsArr: function () {
                        return this.pointsArr;
                    },
                    //计算所有点并存入pointsArr
                    calcPoints: function () {
                        this.pointsArr = [];
                        // console.log('ds.length = ' + this.ds.length);
                        // console.log(this.ds);
                        if (this.ds.length == 0) return;

                        //循环纬度
                        for (var i = 0; i < this.ds.length; i++) {
                            //纬度自增
                            var lat = this.startLat + this.latStep * i;

                            //循环经度
                            for (var j = 0; j < this.ds[i].length; j++) {
                                var lon = this.startLon + this.lonStep * j;
                                // 排除空数据
                                if (this.ds[i][j] != 999999.0) {
                                    var point = new Point(lon, lat);
                                    point.value = this.ds[i][j];
                                    this.pointsArr.push(point);
                                }
                            }
                        }
                    }
               });
            module.exports = DataPoint;
        }, {}],//DataPoint
        3: [function (require, module, exports) {
            var declare = require('dojo/_base/declare');                
            'use strict';
            var GradientColor = declare(null, {
			    startColor: null,
			    endColor: null,
			    step: null,
			    colorArr: [],
			    /**
			     * 参数：
			     * startColor：开始颜色hex
			     * endColor：结束颜色hex
			     * step:几个阶级（几步）
			     */
			    constructor(startColor, endColor, step) {
			      this.startColor = startColor;
			      this.endColor = endColor;
			      this.step = step;
			    },
			    getGradientColorArr: function(startColor, endColor, step) {
			      this.colorArr = [];
			      this.startColor = startColor;
			      this.endColor = endColor;
			      this.step = step;
			
			      var startRGB = this.colorRgb(this.startColor); //转换为rgb数组模式
			      var startR = startRGB[0];
			      var startG = startRGB[1];
			      var startB = startRGB[2];
			
			      var endRGB = this.colorRgb(this.endColor);
			      var endR = endRGB[0];
			      var endG = endRGB[1];
			      var endB = endRGB[2];
			
			      var sR = (endR - startR) / this.step; //总差值
			      var sG = (endG - startG) / this.step;
			      var sB = (endB - startB) / this.step;
			
			      var rgbArr = [];
			      for (var i = 0; i < step; i++) {
			        // //计算每一步的hex值
			        // var hex = this.colorHex(
			        //   'rgb(' +
			        //     parseInt(sR * i + startR) +
			        //     ',' +
			        //     parseInt(sG * i + startG) +
			        //     ',' +
			        //     parseInt(sB * i + startB) +
			        //     ')'
			        // );
			        // this.colorArr.push(hex);
			        rgbArr = [];
			        rgbArr = [parseInt(sR * i + startR), parseInt(sG * i + startG), parseInt(sB * i + startB)];
			        this.colorArr.push(rgbArr);
			      }
			      return this.colorArr;
			    },
			    // 将hex表示方式转换为rgb表示方式(这里返回rgb数组模式)
			    colorRgb: function(sColor) {
			      var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
			      var sColor = sColor.toLowerCase();
			      if (sColor && reg.test(sColor)) {
			        if (sColor.length === 4) {
			          var sColorNew = '#';
			          for (var i = 1; i < 4; i += 1) {
			            sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
			          }
			          sColor = sColorNew;
			        }
			        //处理六位的颜色值
			        var sColorChange = [];
			        for (var i = 1; i < 7; i += 2) {
			          sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)));
			        }
			        return sColorChange;
			      } else {
			        return sColor;
			      }
			    },
			    // 将rgb表示方式转换为hex表示方式
			    colorHex: function(rgb) {
			      var _this = rgb;
			      var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
			      if (/^(rgb|RGB)/.test(_this)) {
			        var aColor = _this.replace(/(?:(|)|rgb|RGB)*/g, '').split(',');
			        var strHex = '#';
			        for (var i = 0; i < aColor.length; i++) {
			          var hex = Number(aColor[i]).toString(16);
			          hex = hex < 10 ? 0 + '' + hex : hex; // 保证每个rgb的值为2位
			          if (hex === '0') {
			            hex += hex;
			          }
			          strHex += hex;
			        }
			        if (strHex.length !== 7) {
			          strHex = _this;
			        }
			        return strHex;
			      } else if (reg.test(_this)) {
			        var aNum = _this.replace(/#/, '').split('');
			        if (aNum.length === 6) {
			          return _this;
			        } else if (aNum.length === 3) {
			          var numHex = '#';
			          for (var i = 0; i < aNum.length; i += 1) {
			            numHex += aNum[i] + aNum[i];
			          }
			          return numHex;
			        }
			      } else {
			        return _this;
			      }
			    }
			  });
            module.exports = GradientColor;
        }, {}],//GradientColor
        4: [function (require, module, exports) { 
            var DataPoints = require('./DataPoints'),
                request = require('dojo/request');
                
            'use strict';
	            /**
			   * 雨量预报数据获取接口，暂时通过Mock获取
			   *
			   *
			   */
			  function RainfallDataAPI() {
			    this.callback = null; //用于回调，传数据
			    this.error = null; //用于回调，返回错误信息
			  }
			
			  /**
			   * 获取欧洲中心降水数据
			   * @param {Date} queryTime 数据日期.
			   * @param {Number[]} validTime 数据时间类型(3、6、12小时降水).
			   *
			   * @returns {JSON} 返回降水JSON数据
			   */
			  RainfallDataAPI.prototype.getEuropeanData = function(queryTime, validTime, callback, error) {
			    var that = this;
			    that.callback = callback;
			    that.error = error;
			
			    $.ajax({
			      type: 'GET',
			      url:
			        'http://61.157.118.158:8088/sndm/api/nafpInterface/getEurNafpEleGridInRectByTimeAndLevelAndValidtime',
			      dataType: 'json',
			      data: { validTime: validTime, times: queryTime }, //请求参数
			      success: function(data) {
			        if (data.returnCode == 0) {
			          //发送请求成功后的操作
			          that.showResult(new DataPoints(data));
			        } else {
			          alert(data.returnMessage);
			        }
			      },
			      error: function() {
			        //发送请求失败后的操作
			        alert('获取数据失败!');
			        that.showError();
			      }
			    });
			
			    // var that = this;
			    // that.callback = callback;
			    // request
			    //   .get(
			    //     '/src/data/欧洲' + validTime + '.json', //请求地址
			    //     {
			    //       handleAs: 'json' //返回的是json数据
			    //     }
			    //   )
			    //   .then(
			    //     function(dt) {
			    //       //发送请求成功后的操作
			    //       that.showResult(new DataPoints(dt));
			    //     },
			    //     function(error) {
			    //       //发送请求失败后的操作
			    //       alert('获取失败' + error);
			    //     }
			    //   );
			  };
			
			  /**
			   * 获取西南区域模式降水数据
			   * @param {Date} queryTime 数据日期.
			   * @param {Number[]} validTime 数据时间类型(3、6、12小时降水).
			   *
			   * @returns {JSON} 返回降水JSON数据
			   */
			  RainfallDataAPI.prototype.getSouthWestData = function(queryTime, validTime, callback, error) {
			    var that = this;
			    that.callback = callback;
			    that.error = error;
			
			    $.ajax({
			      type: 'GET',
			      url:
			        'http://61.157.118.158:8088/sndm/api/nafpInterface/getSiChuanNafpEleGridInRectByTimeAndLevelAndValidtime',
			      dataType: 'json',
			      // jsonp: 'callback', //跨域请求的参数名，默认是 callback
			      // jsonpCallback: 'success_jsonpCallback',
			      data: { validTime: validTime, times: queryTime }, //请求参数
			      success: function(data) {
			        if (data.returnCode == 0) {
			          //发送请求成功后的操作
			          that.showResult(new DataPoints(data));
			        } else {
			          alert(data.returnMessage);
			        }
			      },
			      error: function() {
			        //发送请求失败后的操作
			        alert('获取数据失败!');
			        that.showError();
			      }
			    });
			
			    // var that = this;
			    // that.callback = callback;
			    // request
			    //   .get(
			    //     '/src/data/四川' + validTime + '.json', //请求地址
			    //     {
			    //       handleAs: 'json' //返回的是json数据
			    //     }
			    //   )
			    //   .then(
			    //     function(dt) {
			    //       //发送请求成功后的操作
			    //       that.showResult(new DataPoints(dt));
			    //     },
			    //     function(error) {
			    //       //发送请求失败后的操作
			    //       alert('获取失败' + error);
			    //     }
			    //   );
			  };
			
			  /**
			   * 获取数值预报反演降水数据
			   * @param {Date} queryTime 数据日期.
			   * @param {Number[]} validTime 数据时间类型(3、6、12小时降水).
			   *
			   * @returns {JSON} 返回降水JSON数据
			   */
			  RainfallDataAPI.prototype.getPredictionData = function(queryTime, validTime) {
			    var that = this;
			    that.callback = callback;
			    that.error = error;
			
			    $.ajax({
			      type: 'GET',
			      url: '',
			      dataType: 'jsonp',
			      jsonp: 'callback', //跨域请求的参数名，默认是 callback
			      jsonpCallback: 'success_jsonpCallback',
			      data: { validTime: validTime, times: queryTime }, //请求参数
			      success: function(data) {
			        //发送请求成功后的操作
			        if (data.returnCode == 0) {
			          //发送请求成功后的操作
			          that.showResult(new DataPoints(data));
			        } else {
			          alert(data.returnMessage);
			        }
			      },
			      error: function() {
			        //发送请求失败后的操作
			        alert('获取数据失败!');
			        that.showError();
			      }
			    });
			  };
			
			  // 雷达反演3、6小时降水
			  RainfallDataAPI.prototype.getRadarInversionData = function() {};
			
			  // 回调函数
			  RainfallDataAPI.prototype.showResult = function(result) {
			    this.callback(result);
			  };
			
			  // 错误回调函数
			  RainfallDataAPI.prototype.showError = function(error) {
			    this.error(error);
			  };            
	      	  module.exports = RainfallDataAPI;
        }, { './DataPoints': 2 }],//RainfallDataAPI        
        5: [function (require, module, exports) {
            var GraphicsLayer = require('esri/layers/GraphicsLayer'),
	            Graphic = require('esri/graphic'),
	            SimpleMarkerSymbol = require('esri/symbols/SimpleMarkerSymbol'),
	            SimpleFillSymbol = require('esri/symbols/SimpleFillSymbol'),
	            TextSymbol = require('esri/symbols/TextSymbol'),
	            Font = require('esri/symbols/Font'),
	            Color = require('esri/Color'),
	            SegmentedColor = require('./SegmentedColor'),
                declare = require('dojo/_base/declare');           
                
            'use strict';
            var RainfallLayer = declare(null, {
			    cellCout: 150, //格子数目
			    suiningPolygon: null,
			    suiningExtentPolygon: null,
			    spotGraphicLayer: null, //色斑图
			    layerOpacity: 0.5, // 图层透明度
			    valueGraphicLayer: null, //数值标注图
			    pointsExtentArr: null, //遂宁市 extent 内的点数据
			    pointsArr: null, //遂宁市范围内的点数据
			    lngArr: [],
			    latArr: [],
			    valueExtentArr: [], //遂宁市 extent 内的数值
			    valueArr: [], //遂宁市范围内的点数值
			    period: 16, //色段数目
			    segmentedColorObj: null, //色标分段
			    limitValue: 0.005, // 筛选值
			    constructor: function() {
			      //色斑图
			      this.spotGraphicLayer = new GraphicsLayer();
			      this.spotGraphicLayer.setOpacity(this.layerOpacity);
			      //数值标注图
			      this.valueGraphicLayer = new GraphicsLayer();
			
			      // 获取遂宁范围
			      var suiningwkt =
			        'POLYGON((105.61447 30.97882,105.66577 30.92742,105.72907 30.90762,105.73077 30.86712,105.79307 30.80192,105.77657 30.78382,105.79017 30.71172,105.83467 30.58662,105.87287 30.56022,105.85687 30.51582,105.88107 30.47582,105.92017 30.47012,105.93007 30.52082,105.96747 30.48052,105.95727 30.43052,105.98397 30.41632,105.99727 30.37912,105.93987 30.37482,105.84257 30.41392,105.81657 30.44022,105.76827 30.40672,105.74987 30.36452,105.70547 30.30262,105.72027 30.25742,105.66987 30.25552,105.61927 30.27662,105.61677 30.23702,105.63897 30.18922,105.57657 30.17632,105.55617 30.18552,105.51717 30.20492,105.46967 30.25112,105.42097 30.26322,105.40347 30.29282,105.36717 30.27882,105.35387 30.31092,105.25517 30.28272,105.11687 30.34872,105.08777 30.40352,105.08777 30.46412,105.05697 30.52342,105.06437 30.53802,105.08267 30.55322,105.16497 30.67822,105.16637 30.70842,105.26847 30.75442,105.25707 30.82782,105.22627 30.87832,105.19297 30.89372,105.19337 30.98232,105.17147 31.03682,105.22637 31.10572,105.28477 31.10342,105.37887 31.15462,105.38597 31.11422,105.41317 31.07392,105.50707 31.02952,105.53287 31.02842,105.59147 30.97592,105.61447 30.97882))';
			      var feature = new ol.format.WKT().readFeature(suiningwkt);
			      var json = new ol.format.GeoJSON().writeFeature(feature);
			      this.suiningPolygon = turf.polygon(JSON.parse(json).geometry.coordinates);
			
			      // 加载遂宁范围
			      // var polygon = new esri.geometry.Polygon(JSON.parse(json).geometry.coordinates);
			      // var psymbol = new SimpleFillSymbol();
			      // var pgraphic = new Graphic(polygon, psymbol);
			      // this.spotGraphicLayer.add(pgraphic);
			      // console.log(polygon);
			
			      var suiningExtentwkt = 'POLYGON((104 29,107 29,107 32,104 32,104 29))';
			      var featureExtent = new ol.format.WKT().readFeature(suiningExtentwkt);
			      var jsonExtent = new ol.format.GeoJSON().writeFeature(featureExtent);
			      this.suiningExtentPolygon = turf.polygon(JSON.parse(jsonExtent).geometry.coordinates);
			    },
			
			    //设置数据源
			    setDataPointObjArr: function(dataPointObjArr) {
			      var ptArr = dataPointObjArr.pointsArr;
			      var resultArr = [];
			      var resultExtentArr = [];
			      for (var i = 0; i < ptArr.length; i++) {
			        // 收集遂宁 extent 范围内的点
			        var pointExtent = turf.point([ptArr[i].x, ptArr[i].y]);
			        var resultExtent = turf.booleanContains(this.suiningExtentPolygon, pointExtent);
			        if (resultExtent) {
			          resultExtentArr.push(ptArr[i]);
			        }
			        //收集遂宁市实际范围内的点
			        var point = turf.point([ptArr[i].x, ptArr[i].y]);
			        var result = turf.booleanContains(this.suiningPolygon, point);
			        if (result) {
			          resultArr.push(ptArr[i]);
			        }
			      }
			      this.pointsArr = resultArr;
			      this.pointsExtentArr = resultExtentArr;
			      this.interpolation();
			    },
			    // 添加图层到地图
			    getRainfallLayers: function() {
			      // 添加点数据到数值图层
			      var simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 3);
			
			      var font = new Font('10px', Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLDER);
			
			      for (var i = 0; i < this.pointsExtentArr.length; i++) {
			        var pointArc = this.pointsExtentArr[i];
			        var point = turf.point([pointArc.x, pointArc.y]);
			        // 判断点是否在遂宁市区内
			        var result = turf.booleanContains(this.suiningPolygon, point);
			        if (result) {
			          // 去掉值为 0 的数据
			          if (this.pointsExtentArr[i].value < this.limitValue) {
			            continue;
			          }
			          var textSymbol = new TextSymbol(
			            this.pointsExtentArr[i].value.toFixed(3) + '',
			            font,
			            new Color([0, 0, 0])
			          );
			          textSymbol.setOffset(0, 5);
			          var graphic1 = new Graphic(pointArc, simpleMarkerSymbol);
			          var graphic2 = new Graphic(pointArc, textSymbol);
			          this.valueGraphicLayer.add(graphic1);
			          this.valueGraphicLayer.add(graphic2);
			
			          //隐藏数值
			          this.setValueLayerVisible(false);
			        }
			      }
			
			      return [this.spotGraphicLayer, this.valueGraphicLayer];
			    },
			    // 设置色斑图图层是否可见
			    setSpotLayerVisible: function(isVisible) {
			      this.spotGraphicLayer.setVisibility(isVisible);
			    },
			    //设置数值标注图层是否可见
			    setValueLayerVisible: function(isVisible) {
			      this.valueGraphicLayer.setVisibility(isVisible);
			    },
			
			    // 插值
			    interpolation: function() {
			      this.lngArr = [];
			      this.latArr = [];
			      this.valueExtentArr = []; //数值
			      this.valueArr = [];
			
			      for (var i = 0; i < this.pointsExtentArr.length; i++) {
			        // console.log(this.pointsExtentArr[i]);
			        this.lngArr.push(this.pointsExtentArr[i].x);
			        this.latArr.push(this.pointsExtentArr[i].y);
			        this.valueExtentArr.push(this.pointsExtentArr[i].value);
			      }
			
			      for (var i = 0; i < this.pointsArr.length; i++) {
			        this.valueArr.push(this.pointsArr[i].value);
			      }
			
			      if (this.pointsExtentArr.length == 0) return;
			      // 创建网格 并插值
			      this.createGrid();
			    },
			
			    // 创建格网并插入kriging值
			    createGrid: function() {
			      //获取 lngArr latArr valueExtentArr 最大最小值
			      var rangeminX = this.getMin(this.lngArr);
			      var rangemaxX = this.getMax(this.lngArr);
			      var rangeminY = this.getMin(this.latArr);
			      var rangemaxY = this.getMax(this.latArr);
			      //数据最小值
			      var rangeminValue = this.getMin(this.valueArr);
			      //数据最大值
			      var rangemaxValue = this.getMax(this.valueArr);
			      // 比较最大值和筛选值
			      if (rangeminValue < this.limitValue) rangeminValue = this.limitValue;
			      // 比较最大值和最小值
			      if (rangeminValue > rangemaxValue) rangeminValue = rangemaxValue;
			
			      //引入色标分段
			      this.segmentedColorObj = new SegmentedColor(rangeminValue, rangemaxValue, this.period);
			      this.segmentedColorObj.createSegmentedColor();
			      this.segmentedColorObj.createSegmentedColorValue();
			
			      // 获取范围值
			      var xl = rangemaxX - rangeminX; //经度跨度
			      var yl = rangemaxY - rangeminY; //纬度跨度
			      var gridX = xl / this.cellCout;
			      var gridY = yl / this.cellCout;
			      var lggridx = (rangemaxX - rangeminX) / this.cellCout;
			      var lggridy = (rangemaxY - rangeminY) / this.cellCout;
			
			      // 基于给定点建立克立金插值的范围
			      var gX = rangeminX;
			      var gridPoint = [];
			      var krigingValue = [];
			
			      var variogram = this.getKringVariogram();
			      for (var i = 0; i < this.cellCout; i++) {
			        gX = gX + gridX;
			        var gY = rangeminY;
			        for (var j = 0; j < this.cellCout; j++) {
			          gY = gY + gridY;
			          krigingValue[krigingValue.length] = this.getKring(gX, gY, variogram);
			          gridPoint[gridPoint.length] = [gX, gY];
			        }
			      }
			
			      var zi;
			      // 根据插值创建色块Polygon
			      for (var i = 0; i < this.cellCout * this.cellCout; i++) {
			        var point = turf.point([gridPoint[i][0], gridPoint[i][1]]);
			        var result = turf.booleanContains(this.suiningPolygon, point);
			
			        if (result) {
			          zi = krigingValue[i];
			          // 筛选显示的值
			          if (zi >= this.limitValue) {
			            this.createPolygon(gridPoint[i][0], gridPoint[i][1], zi, lggridx, lggridy);
			          }
			        }
			      }
			    },
			
			    // 初始化kring,获取 变差函数
			    getKringVariogram: function() {
			      var trans = this.lngLatToXY(this.lngArr, this.latArr);
			      var x = trans[0];
			      var y = trans[1];
			      var value = this.valueExtentArr;
			
			      var model = 'spherical';
			      var sigma2 = 0;
			      var alpha = this.cellCout;
			      var variogram = kriging.train(value, x, y, model, sigma2, alpha);
			      return variogram;
			    },
			
			    // 基于多边形的位置，得到克里金值。
			    getKring: function(xk, yk, variogram) {
			      var xnew, ynew /* Pair of new coordinates to predict */;
			      var arr = esri.geometry.lngLatToXY(xk, yk);
			      var tpredicted = kriging.predict(arr[0], arr[1], variogram);
			
			      return tpredicted;
			    },
			
			    // 将给定的纬度和经度值转换为Web墨卡托。
			    lngLatToXY: function(lngArr, latArr) {
			      var xArr = [];
			      var yArr = [];
			      for (var i = 0; i < lngArr.length; i++) {
			        var arr = esri.geometry.lngLatToXY(lngArr[i], latArr[i]);
			        if (arr.length == 2) {
			          xArr[i] = arr[0];
			          yArr[i] = arr[1];
			        }
			      }
			      return [xArr, yArr];
			    },
			
			    createPolygon: function(xi, yi, zi, lggridx, lggridy) {
			      var polygonJson = {
			        rings: [[[xi - lggridx, yi - lggridy], [xi, yi - lggridy], [xi, yi], [xi - lggridx, yi]]],
			        spatialReference: {
			          wkid: 4326
			        }
			      };
			      var polygon = new esri.geometry.Polygon(polygonJson);
			      var simpleFillSymbol = new SimpleFillSymbol();
			      simpleFillSymbol.setOutline(null);
			
			      var colorArr = this.segmentedColorObj.getGradientColorArr();
			      var colorValueArr = this.segmentedColorObj.getGradientColorValueArr();
			
			      var index = this.searchIndex(colorValueArr, zi);
			      if (index != -1 && index < colorArr.length) {
			        simpleFillSymbol.setColor(new esri.Color(colorArr[index]));
			      }
			
			      var graphic = new Graphic(polygon, simpleFillSymbol);
			      this.spotGraphicLayer.add(graphic);
			    },
			
			    getMin: function(arr) {
			      return Math.min.apply(null, arr);
			    },
			    getMax: function(arr) {
			      return Math.max.apply(null, arr);
			    },
			    // 移除图层
			    removeRainfallLayer: function(map) {
			      map.removeLayer(this.spotGraphicLayer);
			      map.removeLayer(this.valueGraphicLayer);
			    },
			
			    // 二分法查找，返回索引
			    searchIndex: function(arr, key) {
			      for (var i = 0; i < arr.length; i++) {
			        if (i + 1 < arr.length) {
			          if (key >= arr[i] && key <= arr[i + 1]) {
			            return i;
			          }
			        }
			      }
			      return 0;
			    }
			  });

            module.exports = RainfallLayer;
        }, { './SegmentedColor': 2 }],//RainfallLayer  
        6: [function (require, module, exports) {
        	
            var GradientColor = require('./GradientColor'),
                declare = require('dojo/_base/declare');                
            'use strict';
            var SegmentedColor = declare(null, {
			    colorPonitArr: [], // 色点数据 依据这个数据进行色段划分
			    gradientColorObj: null, // 渐变颜色生成对象
			    minValue: 0,
			    maxValue: 0,
			    colorSegmCount: 0, // 色段数
			    gradientColorArr: [], // 生成的渐变色数组
			    gradientColorValueArr: [], // 生成的渐变色数组对应的数据,用于绘制
			
			    /**
			     *
			     * @param {Number} minValue 最小值
			     * @param {Number} maxValue 最大值
			     * @param {Number} colorSegmCount 色段数 3的倍数
			     */
			    constructor(minValue, maxValue, colorSegmCount) {
			      this.colorPonitArr = [];
			      this.colorPonitArr.push([0, 0, 255]); // 蓝
			      this.colorPonitArr.push([0, 255, 0]); // 绿
			      this.colorPonitArr.push([255, 255, 0]); // 黄
			      this.colorPonitArr.push([255, 0, 0]); // 红
			      this.gradientColorObj = new GradientColor();
			
			      this.minValue = minValue;
			      this.maxValue = maxValue;
			      this.colorSegmCount = colorSegmCount;
			      this.gradientColorArr = [];
			      this.gradientColorValueArr = [];
			
			      this.calcGradientColorValue();
			      this.calcGradientColor();
			    },
			
			    // 计算渐变色并存到数组gradientColorArr
			    calcGradientColor: function() {
			      // 两两颜色分段，计算相邻颜色之间需要计算的色段数
			      var segment = this.colorSegmCount / this.colorPonitArr.length;
			      for (var i = 0; i < this.colorPonitArr.length; i++) {
			        if (i + 1 < this.colorPonitArr.length) {
			          var jiangedian = 0;
			          if (i == 0) jiangedian = segment + 2;
			          else jiangedian = segment + 1;
			          // console.log('segment:' + jiangedian);
			          //获取分段
			          var arr = [];
			          arr = this.gradientColorObj.getGradientColorArr(
			            this.rgbArrToHex(this.colorPonitArr[i]),
			            this.rgbArrToHex(this.colorPonitArr[i + 1]),
			            jiangedian
			          );
			          this.gradientColorArr = this.gradientColorArr.concat(arr);
			        }
			      }
			    },
			
			    // 计算渐变色对应的值，并存到数组 gradientColorValueArr
			    calcGradientColorValue: function() {
			      var step = (this.maxValue - this.minValue) / (this.colorSegmCount - 1);
			      for (var i = 0; i < this.colorSegmCount; i++) {
			        this.gradientColorValueArr.push((i * step + this.minValue).toFixed(4));
			      }
			    },
			
			    // 创建色标段
			    createSegmentedColor() {
			      var segmentedColor = document.getElementById('segmentedColor');
			      segmentedColor.innerHTML = '';
			
			      var segmentedColorWidth = segmentedColor.offsetWidth;
			      var segmentedColorHeight = segmentedColor.offsetHeight - 1;
			
			      var width = (segmentedColorWidth / this.gradientColorArr.length - 0.1).toFixed(1);
			
			      for (var i = 0; i < this.gradientColorArr.length; i++) {
			        var rgb = 'rgb(' + this.gradientColorArr[i] + ')';
			        var segment =
			          "<div style='background-color:" +
			          rgb +
			          ';' +
			          'width:' +
			          width +
			          'px;height:' +
			          segmentedColorHeight +
			          "px;float:left'></div>";
			
			        segmentedColor.innerHTML += segment;
			      }
			    },
			    createSegmentedColorValue() {
			      var segmentedColorValue = document.getElementById('segmentedColorValue');
			      segmentedColorValue.innerHTML = '';
			      var segmentedColorValueWidth = segmentedColorValue.offsetWidth;
			      var segmentedColorValueHeight = segmentedColorValue.offsetHeight;
			
			      var len = this.gradientColorValueArr.length;
			      var width = (segmentedColorValueWidth / len - 0.1).toFixed(1);
			
			      var start = "<span style='float:left'>" + this.gradientColorValueArr[0] + '</span>';
			      segmentedColorValue.innerHTML += start;
			      var end = "<span style='float:right'>" + this.gradientColorValueArr[len - 1] + '</span>';
			      if (this.gradientColorValueArr[0] != this.gradientColorValueArr[len - 1]) {
			        segmentedColorValue.innerHTML += end;
			      }
			      // for (var i = 0; i < this.gradientColorValueArr.length; i++) {
			      //   console.log(i);
			      //   if (i % 4 == 0 || i == this.gradientColorValueArr.length - 1) {
			      //     var wd = width;
			      //     if (i == 0) {
			      //       wd = 0;
			      //     } else {
			      //       wd = wd * 2.4; //宽度有问题需要修改
			      //     }
			      //     console.log('i：' + i + ' =' + this.gradientColorValueArr[i]);
			      //     var segment =
			      //       "<span style='margin-left: " + wd + "px;'>" + this.gradientColorValueArr[i] + '</span>';
			
			      //     segmentedColorValue.innerHTML += segment;
			      //   }
			      // }
			    },
			
			    // 获取计算后的渐变色
			    getGradientColorArr: function() {
			      return this.gradientColorArr;
			    },
			
			    // 获取计算后的渐变色的值
			    getGradientColorValueArr: function() {
			      return this.gradientColorValueArr;
			    },
			
			    // 颜色数组转化为16进制
			    rgbArrToHex: function(arr) {
			      var hex = '#' + ((1 << 24) + (arr[0] << 16) + (arr[1] << 8) + arr[2]).toString(16).slice(1);
			      return hex;
			    }
			  });

            module.exports = SegmentedColor;
        }, {'./GradientColor':3}],//SegmentedColor 
    }, {}, [1])(1)
});